<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui">
    <title></title>
    <link href="https://cdn.bootcss.com/mui/3.7.1/css/mui.min.css" rel="stylesheet">
    <link rel="stylesheet" href="//cdn.midoci.com/HZY/admin/css/clearStyleApp.css">
    <link rel="stylesheet" href="//zaoqi.oss-cn-beijing.aliyuncs.com/finance_c2c/c2cshare/css/style.css">
    <script src="//cdn.midoci.com/HZY/admin/js/remSrv.js"></script>
    <style>
        body {
            margin: 0 auto;
        }
    </style>

</head>
<body>
测试分享
</body>
<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>

    // 分享 start
    $(document).ready(function () {

        var url = window.location.href;
        alert(url)
        $.ajax({
            type: 'GET',
            url: 'https://c2c.kalaibao.com/mp/share',
            data: {"url": url},
            success: function (data) {
                var appid = data.appid;
                var timestamp = data.timestamps;
                var nonceStr = data.nonceStr;
                var signature = data.signatures;
                wx_share(appid, timestamp, nonceStr, signature)
            },
            error: function (request) {
                console.log("Connection error");
            }
        });
    });


    function wx_share(appid, timestamp, nonceStr, signature) {
        //分享
        var link = "https://shop.kalaibao.com/mp/c2c_share";
        wx.config({
            debug: true,
            appId: appid,
            timestamp: timestamp,
            nonceStr: nonceStr,
            signature: signature,
            jsApiList: [
                'checkJsApi',
                'onMenuShareTimeline',
                'onMenuShareAppMessage',
                'onMenuShareQQ',
                'onMenuShareWeibo']
        });

        var shareAppData = {
            title: '测试分享',
            desc: '0成本加盟，超过10家银行金融产品。人人分享、锁定团队。年薪百万不是梦',
            link: link,  // 必须跟当前域名保持一致
            imgUrl: 'https://zaoqi.oss-cn-beijing.aliyuncs.com/finance_c2c/c2cshare/images/share.jpg',
            trigger: function () {
            }
        };


        var shareTimelineData = {
            title: '测试分享',
            desc: '0成本加盟，超过10家银行金融产品。人人分享、锁定团队。年薪百万不是梦',
            link: link,  // 必须跟当前域名保持一致
            imgUrl: 'https://zaoqi.oss-cn-beijing.aliyuncs.com/finance_c2c/c2cshare/images/share.jpg',
            trigger: function () {
            }
        };

        wx.ready(function () {
            wx.onMenuShareAppMessage(shareAppData); // 分享跟朋友
            wx.onMenuShareTimeline(shareTimelineData); //分享到朋友圈
        });
    }
</script>
</html>
